package com.ruoyi.labdata.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ruoyi.labdata.mapper.LabGasCylinderNumberMapper;
import com.ruoyi.labdata.domain.LabGasCylinderNumber;
import com.ruoyi.labdata.service.ILabGasCylinderNumberService;

/**
 * 危化气瓶数量Service业务层处理
 * 
 * @author winner pan
 * @date 2022-02-07
 */
@Service
public class LabGasCylinderNumberServiceImpl implements ILabGasCylinderNumberService {
	@Autowired
	private LabGasCylinderNumberMapper labGasCylinderNumberMapper;

	/**
	 * 查询危化气瓶数量
	 * 
	 * @param cylinderNumberId
	 *            危化气瓶数量ID
	 * @return 危化气瓶数量
	 */
	@Override
	public LabGasCylinderNumber selectLabGasCylinderNumberById(Long cylinderNumberId) {
		return labGasCylinderNumberMapper.selectLabGasCylinderNumberById(cylinderNumberId);
	}

	/**
	 * 查询危化气瓶数量列表
	 * 
	 * @param labGasCylinderNumber
	 *            危化气瓶数量
	 * @return 危化气瓶数量
	 */
	@Override
	public List<LabGasCylinderNumber> selectLabGasCylinderNumberList(LabGasCylinderNumber labGasCylinderNumber) {
		return labGasCylinderNumberMapper.selectLabGasCylinderNumberList(labGasCylinderNumber);
	}

	/**
	 * 新增危化气瓶数量
	 * 
	 * @param labGasCylinderNumber
	 *            危化气瓶数量
	 * @return 结果
	 */
	@Override
	@Transactional
	public int insertLabGasCylinderNumber(LabGasCylinderNumber[] labGasCylinderNumbers) {
		for (LabGasCylinderNumber item : labGasCylinderNumbers) {
			if (item.getCylinderNumberId() != null) {
				if (item.getCylindersNum() == null) {
					item.setCylindersNum(Integer.valueOf(0));
				}
				labGasCylinderNumberMapper.updateLabGasCylinderNumber(item);
			} else if (item.getCylindersNum() != null && item.getCylindersNum() > 0) {
				labGasCylinderNumberMapper.insertLabGasCylinderNumber(item);
			}
		}
		return 1;
	}

	/**
	 * 修改危化气瓶数量
	 * 
	 * @param labGasCylinderNumber
	 *            危化气瓶数量
	 * @return 结果
	 */
	@Override
	public int updateLabGasCylinderNumber(LabGasCylinderNumber labGasCylinderNumber) {
		return labGasCylinderNumberMapper.updateLabGasCylinderNumber(labGasCylinderNumber);
	}

	/**
	 * 批量删除危化气瓶数量
	 * 
	 * @param cylinderNumberIds
	 *            需要删除的危化气瓶数量ID
	 * @return 结果
	 */
	@Override
	public int deleteLabGasCylinderNumberByIds(Long[] cylinderNumberIds) {
		return labGasCylinderNumberMapper.deleteLabGasCylinderNumberByIds(cylinderNumberIds);
	}

	/**
	 * 删除危化气瓶数量信息
	 * 
	 * @param cylinderNumberId
	 *            危化气瓶数量ID
	 * @return 结果
	 */
	@Override
	public int deleteLabGasCylinderNumberById(Long cylinderNumberId) {
		return labGasCylinderNumberMapper.deleteLabGasCylinderNumberById(cylinderNumberId);
	}
	
	public int scaninGasCylinderNumber(LabGasCylinderNumber labGasCylinderNumber){
		return labGasCylinderNumberMapper.scaninGasCylinderNumber(labGasCylinderNumber);
	}
    public int scanoutGasCylinderNumber(LabGasCylinderNumber labGasCylinderNumber){
    	return labGasCylinderNumberMapper.scanoutGasCylinderNumber(labGasCylinderNumber);
    }
}
